<?php

namespace App\Logic;

use App\Models\Bebaviour;
use App\Models\RealEstates;
use App\server\RedisServer;
use Dflydev\DotAccessData\Data;
use Illuminate\Support\Facades\Redis;

class HouseReLogic
{
    /**
     * @function
     */
    public static function bviOurIdLogic($user_id)
    {
        return Bebaviour::bviOurID('id', $user_id);
    }

    /**
     * @functin  展示数据列表
     * @return mixed
     */
    public static function realList()
    {
        return RealEstates::list();
    }


    /**
     * @name wl
     * @function 信息存入有序集合中
     */
    public static function listReal()
    {
        $sqlReal = RealEstates::list()->toArray();
        foreach ($sqlReal['data'] as $value) {
            $redis = RedisServer::createRedisObject();
            $redis->select(11);
            $redis->zadd('house_popularity', $value['sort'], $value['id']);
            $popularHouses = $redis->zRevRange('house_popularity', 0, 4);  // 取出人气排行前5的楼盘信息
        }
        $houses = RealEstates::realId('id', $popularHouses); // 根据楼盘id查询对应的楼盘信息

        dd($houses);

        return $houses;
    }
}
